home *** CD-ROM | disk | FTP | other *** search
-
- **********************************************************
- * ExeBB v1.1 22.12.1994 *
- **********************************************************
- * copyright (c) 1994 by Jens Tröger, all rights reserved *
- * this is FREEWARE *
- **********************************************************
- * written using HiSoft`s DevPac 3.04 *
- * greets fly to Oliver Reiff, "PackMAN" Falk Zühlsdorff *
- * "Janosh" Jan Stötzer, Jan van den Baard,... *
- **********************************************************
- * (non)sense: this will read the Bootblock from a given *
- * floppy-drive and execute it *
- * works with KS1.2 and better *
- * USAGE: ExeBB <unit> *
- **********************************************************
-
- opt o+,p+
-
- move.l a0,a5
-
- ; ----- alloc memory for bootblock and several structures
-
- alloc_mem move.l 4.w,a6
- move.l #1024+88+1,d0 ; Bootblock + Port/IO...
- move.l #$10001,d1
- jsr -198(a6) ; _LVOAllocMem
- move.l d0,a4 ; a4: PTR to mem
- beq exit
-
- ; ----- open dos.library
-
- open_dos lea dosname(pc),a1
- moveq #33,d0
- jsr -552(a6) ; _LVOOpenLibrary
- move.l d0,d6 ; d6: DOSBase
- beq free_mem
-
- ; ----- get unit
-
- read_unit cmp.b #"d",(a5)+
- bne usage
- cmp.b #"f",(a5)+
- bne usage
- moveq #0,d0
- move.b (a5)+,d0
- sub.b #48,d0
- cmp.b #4,d0
- bge usage
- cmp.b #0,d0
- blt usage
- move.l d0,d2 ; d2: Unit
- cmp.b #":",(a5)+
- bne usage
-
- ; ----- add MessagePort to system
-
- add_port sub.l a1,a1
- jsr -294(a6) ; _LVOFindTask
- move.l d0,1024+16(a4)
- lea 1024(a4),a1
- jsr -354(a6) ; _LVOAddPort
-
- ; ----- open trackdisk.device
-
- open_track lea trackname(pc),a0
- lea 1024+32(a4),a1 ; a1: DiskIO-Struc
- move.l d2,d0
- moveq #0,d1
- jsr -444(a6) ; _LVOOpenDevice
- tst.l d0
- bne err_nodev ; FATAL !!!!!
-
- ; ----- read bootblock
-
- read_bb lea 1024+46(a4),a0 ; a0: RepPort
- lea 1024(a4),a1 ; a1: ReplyPort-Struc
- move.l a1,(a0)
- lea 1024+32(a4),a1 ; a1: DiskIO-Struc
- move.w #2,28(a1)
- move.l #1024,36(a1)
- move.l a4,40(a1)
- move.l #0,44(a1)
- jsr -456(a6) ; _LVODoIO
- move.l d0,d2
- move #9,28(a1)
- move.l #0,36(a1)
- jsr -456(a6) ; _LVODoIO
- tst.l d2
- bne err_nodoio
-
- ; ----- ask before executing the bootcode
-
- ask move.l d6,a6
- lea ask_text(pc),a2
- moveq #ask_text_end-ask_text,d3
- bsr write_msg
- jsr -54(a6) ; _LVOInput
- move.l d0,d1
- lea 1024+88(a4),a0
- move.l a0,d2
- moveq #1,d3
- jsr -42(a6)
- move.l 4.w,a6 ; _LVORead
- lea 1024+88(a4),a0
- cmp.b #"Y",(a0)
- bne.s close_dev
-
- ; ----- execute code
-
- execute_bb movem.l d0-d7/a0-a6,-(sp)
- lea 1024+32(a4),a1 ; a1: io-struc of trackdisk
- jsr $0c(a4) ; BB_BootCode
- movem.l (sp)+,d0-d7/a0-a6
-
- ; ----- close trackdisk.device
-
- close_dev lea 1024+32(a4),a1 ; a1: DiskIO-Struc
- jsr -450(a6) ; _LVOCloseDevice
-
- ; ----- remove port
-
- rem_port lea 1024(a4),a1 ; a1: ReplyPort
- jsr -360(a6) ; _LVORemPort
-
- ; ----- close dos.library
-
- close_dos move.l 4.w,a6
- move.l d6,a1
- jsr -414(a6) ; _LVOCloseLibrary
-
- ; ----- free allocated memory
-
- free_mem move.l a4,a1
- move.l #1024+88+1,d0
- jsr -210(a6) ; _LVOFreeMem
-
- ; ----- returncode: 0
-
- exit moveq #0,d0
- rts
-
- ; ----- several messages
-
- usage lea usage_text(pc),a2
- move.l #usage_text_end-usage_text,d3
- bsr.s write_msg
- bra close_dos
-
- err_nodev lea err1_text(pc),a2
- moveq #38,d3
- bsr.s write_msg
- move.l 4.w,a6
- lea 1024(a4),a1 ; a1: ReplyPort
- jsr -360(a6) ; _LVORemPort
- bra.s close_dos
-
- err_nodoio lea err2_text(pc),a2
- moveq #44,d3
- bsr.s write_msg
- move.l 4.w,a6
- lea 1024+32(a4),a1 ; a1: DiskIO-Struc
- jsr -450(a6) ; _LVOCloseDevice
- lea 1024(a4),a1 ; a1: ReplyPort
- jsr -360(a6) ; _LVORemPort
- bra.s close_dos
-
- ; ----- write text to stdout
-
- write_msg move.l d6,a6
- jsr -60(a6) ; _LVOOutput
- move.l d0,d1
- move.l a2,d2
- jmp -48(a6) ; _LVOWrite
-
- ; ----- names, texts
-
- dosname dc.b "dos.library",0
- even
- trackname dc.b "trackdisk.device",0
- even
- err1_text dc.b "FATAL ERROR opening trackdisk.device.",10
- even
- err2_text dc.b "Error reading Bootblock. No disk inserted ?",10
- even
- ask_text dc.b "Are you shure to execute the bootcode ?? This may"
- dc.b " cause a system crash !",10
- dc.b "Enter [Y] to execute, any other to cancel: "
- ask_text_end
- usage_text dc.b 10,$9b,"1mExeBB v1.1",$9b,"0m 1994 by Jens Tröger",10
- dc.b "USAGE: ExeBB <unit>",10
- dc.b "Where <unit> is one of your mounted floppies (df0:) ",10,10
- usage_text_end
-
- end
-